//
//  M_Letter.m
//  suRead
//
//  Created by 李 诗洋 on 16/1/2.
//  Copyright © 2016年 bao. All rights reserved.
//

#import "M_Letter.h"

@implementation M_Letter

+ (NSDictionary *)JSONKeyPathsByPropertyKey
{
    return @{
             @"f_title": @"title",
             @"f_addtime":@"addtime"
             };
}

+ (NSValueTransformer *)f_addtimeJSONTransformer {
    
    return [MTLValueTransformer transformerUsingForwardBlock:^(NSNumber *value_, BOOL *success, NSError **error){
        
        if (!value_) {
            return @"";
        }
        
        double timeInterval = [value_ doubleValue];
        NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
        [formatter setDateStyle:NSDateFormatterMediumStyle];
        [formatter setTimeStyle:NSDateFormatterShortStyle];
        [formatter setDateFormat:@"MM-dd HH:mm"];
        
        //时间戳转时间的方法
        NSDate *confromTimesp = [NSDate dateWithTimeIntervalSince1970:timeInterval];
        NSString *confromTimespStr = [formatter stringFromDate:confromTimesp];
        
        return confromTimespStr;
        
    }];
}

@end
